package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallMessageRecord;
import com.tencreat.mapper.mall.MallMessageRecordMapper;
import com.tencreat.service.mall.IMallMessageRecordService;
import org.springframework.stereotype.Service;

/**
 * 消息记录Service业务层处理
 *
 * @author tencreat
 * @date 2021-11-24
 */
@Service
public class MallMessageRecordServiceImpl extends ServiceImpl<MallMessageRecordMapper, MallMessageRecord> implements IMallMessageRecordService {


    /**
     * 查询消息记录
     *
     * @param id 消息记录ID
     * @return 消息记录
     */
    @Override
    public MallMessageRecord selectMallMessageRecordById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询消息记录列表
     *
     * @param mallMessageRecord 消息记录
     * @return 消息记录
     */
    @Override
    public List<MallMessageRecord> selectMallMessageRecordList(MallMessageRecord mallMessageRecord) {
        return baseMapper.selectList(Wrappers.query(mallMessageRecord));
    }

    /**
     * 新增消息记录
     *
     * @param mallMessageRecord 消息记录
     * @return 结果
     */
    @Override
    public int insertMallMessageRecord(MallMessageRecord mallMessageRecord) {
        mallMessageRecord.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallMessageRecord);
    }

    /**
     * 修改消息记录
     *
     * @param mallMessageRecord 消息记录
     * @return 结果
     */
    @Override
    public int updateMallMessageRecord(MallMessageRecord mallMessageRecord) {
        mallMessageRecord.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallMessageRecord);
    }

    /**
     * 批量删除消息记录
     *
     * @param ids 需要删除的消息记录ID
     * @return 结果
     */
    @Override
    public int deleteMallMessageRecordByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除消息记录信息
     *
     * @param id 消息记录ID
     * @return 结果
     */
    @Override
    public int deleteMallMessageRecordById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
